//
// Created by Administrator on 2021/3/1.
//

#ifndef GTK_CACULATOR_CALCULATOR_H
#define GTK_CACULATOR_CALCULATOR_H

#include "operation.h"

#define MAX_CHAR 13 // 希望展示出来有6位有效数字, 比如 +-1.56805e+-015 (正负1.56805乘以10的正负15次方)
//↑ todo 怎么知道的 13个char 等于 6位有效数字

// 输入过程中 需要记录之前输入的状态
typedef struct {
  char input_buffer[MAX_CHAR + 1]; //一个数最多这么大
  int input_buffer_position;
  double result;

  Operation previous_operation;
  Operation current_operation;
  void (*display_text)(char *); //用来输出一个字符串
} CalcContext;

int HandleInput(CalcContext *context, char input_value);

CalcContext *CreateCalcContext();

void DestroyCalcContext(CalcContext **p_context);

#endif //GTK_CACULATOR_CALCULATOR_H
